<?php 
/*
 * Smarty plugin
 * -------------------------------------------------------------
 * File:	function.getdatebyweekdaystartdate.php
 * Type:	function
 * Name:	getdatebyweekdaystartdate
 * Purpose:	Return a specific date given the weekday, startdate. 
 * Optional params: weekafter for number of weeks after startdate and dateformat
 * -------------------------------------------------------------
 */
function smarty_function_getdatebyweekdaystartdate($params, &$smarty)
{
	if(empty($params['weekday']) || empty($params['startdate'])){
		return '-' ;
	}
	try {
		$week = empty($params['weeksafter'])?0:intval($params['weeksafter']);
		$output = getDateByWeekdayStartDate($params['weekday'],$params['startdate'], $week, $params['dateformat']);
	}
	catch(Exception $e) {
		return '<Pluging error>';
	}
    
    return $output;
}
?>